These functions perform operations on lists which represent sets of elements.
This function searches list for an element matching item. If a match is found, it returns the cons cell whose
carwas the matching element. Otherwise, it returnsnil. Elements are compared byeqlby default; you can use the:test,:test-not, and:keyarguments to modify this behavior. See Sequences.Note that this function's name is suffixed by ‘*’ to avoid the incompatible
memberfunction defined in Emacs. (That function usesequalfor comparisons; it is equivalent to(member*item list:test 'equal).)
The member-if
and member-if-not functions analogously search for
elements which satisfy a given predicate.
This function returns
tif sublist is a sublist of list, i.e., if sublist iseqlto list or to any of itscdrs.
This function conses item onto the front of list, like
(consitem list), but only if item is not already present on the list (as determined bymember*). If a:keyargument is specified, it is applied to item as well as to the elements of list during the search, on the reasoning that item is “about” to become part of the list.
This function combines two lists which represent sets of items, returning a list that represents the union of those two sets. The result list will contain all items which appear in list1 or list2, and no others. If an item appears in both list1 and list2 it will be copied only once. If an item is duplicated in list1 or list2, it is undefined whether or not that duplication will survive in the result list. The order of elements in the result list is also undefined.
This is a destructive version of
union; rather than copying, it tries to reuse the storage of the argument lists if possible.
This function computes the intersection of the sets represented by list1 and list2. It returns the list of items which appear in both list1 and list2.
This is a destructive version of
intersection. It tries to reuse storage of list1 rather than copying. It does not reuse the storage of list2.
This function computes the “set difference” of list1 and list2, i.e., the set of elements that appear in list1 but not in list2.
This is a destructive
set-difference, which will try to reuse list1 if possible.
This function computes the “set exclusive or” of list1 and list2, i.e., the set of elements that appear in exactly one of list1 and list2.